/**
 * here. I define object when send data to server
 */
var Util = function() {
};
Util.prototype = {
	ajax : function(type, url, dataType, action, data) {
		return $.ajax({
			type : type,
			url : url,
			dataType : dataType,
			data : {
				action : action,
				data : data
			}
		});
	}
};

/**
 * here. I will define note object
 * 
 */
var util = new Util();
function Note() {
	this.data = {};
	this.init = function(subject, content, time, start, end, firstTitle,
			secondTitle, note, status, commonStatus) {
		this.data.subject = subject || "";
		this.data.content = content || "";
		this.data.time = time || "";
		this.data.start = start || "";
		this.data.end = end || "";
		this.data.firstTitle = firstTitle || "";
		this.data.secondTitle = secondTitle || "";
		this.data.note = note || "";
		this.data.status = status || "";
		this.data.commonStatus = commonStatus || "";
	};

	this.showData = function() {
	};
	this.sendData = function(url, type, dataType, action, ajaxData) {
		var ajax = util.ajax(type, url, dataType, action, ajaxData);
		ajax
				.done(function(resp) { // show data after recevie data from
					// server
					console.log(resp);
					var oTable;
					ajax
							.done(function(resp) {
								var i = 0;
								oTable = $('#example')
										.dataTable(
												{
													"sDom" : "<'row'<'col-md-3'l>r>t<'row'<'col-md-3'i><'col-md-3 col-md-offset-4'p>>",
													"sPaginationType" : "bootstrap",
													"aoColumns" : [
													/* キー */null,
													/* プロジェクト */null,
													/* 件名 */null,
													/* 優先度 */null,
													/* 登録日 */null,
													/* 期限日 */null,
													/* 更新日 */null,
													/* 登録者 */null,
													/* 状態 */null, ],
													"aoColumnDefs" : [ {
														"bSortable" : true,
														"aTargets" : [ 0 ]
													}, {
														"bSortable" : false,
														"aTargets" : [ 1 ]
													}, {
														"bSortable" : false,
														"aTargets" : [ 2 ]
													}, {
														"bSortable" : false,
														"aTargets" : [ 3 ]
													}, {
														"bSortable" : false,
														"aTargets" : [ 4 ]
													}, {
														"bSortable" : false,
														"aTargets" : [ 5 ]
													}, {
														"bSortable" : false,
														"aTargets" : [ 6 ]
													}, {
														"bSortable" : false,
														"aTargets" : [ 7 ]
													}, {
														"bSortable" : false,
														"aTargets" : [ 8 ]
													} ],
													"bDeferRender" : true,
													"aaData" : resp.aaData,
													"aLengthMenu" : [
															[ 10, 25, 50 ],
															[ 10, 25, 50 ] ],
													"aaSorting" : [ [ 0, "asc" ] ],
													"oLanguage" : {
														"sLengthMenu" : "_MENU_ ページにレコード数",
														"sZeroRecords" : "Nothing found - sorry",
														"sInfoEmpty" : "Showing 0 to 0 of 0 records",
														"sInfoFiltered" : "(filtered from _MAX_ total records)",
														"oPaginate" : {
															"sPrevious" : "前",
															"sNext" : "次 "
														}
													}

												});

							});

					ajax.fail(function(error) {
						alert("FAQ取得エラー。再試行してください");
					});

				});
		ajax.fail(function(error) { // error });
		})
	};

}